//*********************************************************
//
// Output Registers used:
//   oPos - The vertex output position.
//   oT0  - original UV
//
// Constant Registers used:
//   c[0-3] - Model view projection matrix.
//   c[4]      - Material diffuse.
//   c[5]      - Material emissive.
//   c[8] - Model-space light direction.
//   c[9].x - Max shadow length
//
//*********************************************************

// r1 = light_pos - pos
// oPos = MVP * p2

dp3 r3.x, c[VL_MODEL_SPACE_LIGHT_DIR_SHADOWLENGTH], inNormal	; r3.x = (Light direction * Normal)
slt r3.x, r3.x, c[CONSTANT_0_05_1_2].x		; r3.x = (r3.x < 0) ? 1 : 0

mul r2.xyz, c[VL_MODEL_SPACE_LIGHT_DIR_SHADOWLENGTH], r3.x	; light direction * (r3.x < 0)
mul r2.xyz, r2, c[VL_MODEL_SPACE_LIGHT_DIR_SHADOWLENGTH].w	; light direction * max_shadow_length * (r3.x < 0)

sub r1.xyz, inPos, r2
mov r1.w, c[CONSTANT_0_05_1_2].z

m4x4 r0, r1, c[MODEL_VIEW_PROJECTION]
mov oPos, r0

// oT0 = texcoord
mov oT0, inUV
mov oD0, c[CONSTANT_0_05_1_2].yyzy
mov oD1, c[CONSTANT_0_05_1_2].x
